
* create a dataset for the Melbourne GPO_distance


clear
set obs 1

gen x = 144.9626 in 1
gen y = -37.8124 if _n==1

save Data/GPO.dta, replace


use Data/BuildingType.dta, clear

merge m:1 postcode using Data/PostcodeArea.dta
	drop _merge
	
	
merge m:1 postcode using Data/SA3postcode.dta
drop _merge
merge m:1 SA3_CODE16 using "data/maps/sa3" 

keep if _merge ==3
drop _merge
*  melbourne

gen Melbourne = 1 if SA4_CODE=="213" | SA4_CODE =="210" | SA4_CODE=="209" | SA4_CODE =="207" | SA4_CODE=="211"  | SA4_CODE=="208" | SA4_CODE=="206" | SA4_CODE=="212"
replace Melbourne =0 if Melbourne ==.

gen Mornington = 1 if SA4_CODE =="214"
replace Mornington = 0 if Mornington ==.

gen Geelong = 1 if SA4_CODE=="203"
replace Geelong = 0 if Geelong ==.


gen Country = 1 if Melbourne ==0 & Mornington == 0 & Geelong==0
replace Country =0 if Country==.


merge m:1 postcode using Data/Postcode_matching.dta
keep if _merge ==3
drop _merge


	*keep if id 	<=1380 & id> 683 // keep Vic only 

	
	
	
		
	gen roofratio = ROOFME/ROOFTI
gen PROOFME = ROOFME/RESIDENTIALBUILDINGS	
	gen roofrelative = (ROOFME/ROOFTI )* RESIDENTIALBUILDINGS
	
	replace roofrelative = round(roofrelative,1)
	
	
		
		

			gen roofrelative_middle = roofrelative if GPO_distance > 5 & GPO_distance < 20 & Melbourne==1 


			gen roofrelative_inner = roofrelative if GPO_distance <=5  & Melbourne==1 

				

			gen roofrelative_outer = roofrelative if GPO_distance >= 20 & Melbourne==1 

				
			
			
				
		spmap roofrelative_middle using Data/poa_coord if Melbourne ==1 , id(id) fcolor(Greys2)   ///
		 clmethod(custom) ndfcolor(bluishgray) ndocolor(white) ndsize(0.001pt)  osize(0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt) ocolor(white 			white white white white white white white white white )  clbreaks(0 1715 4038 6978 9703 13374 16587 21031 24555 35492 86616)     ///
		legend(off) point(data("Data/GPO.dta") xcoord(x) ycoord(y) size(medlarge) fcolor(gs0) ocolor(white) osize(1.5pt)) scalebar(units(10) scale(89.5)  label(Kilometers) xpos(100))
		
		
		graph export Analysis/roofrelative_Melbmiddlefull.png, replace

		
		
		spmap roofrelative_inner using Data/poa_coord if Melbourne ==1 , id(id) fcolor(Greys2)   ///
		 clmethod(custom) ndfcolor(bluishgray) ndocolor(white) ndsize(0.001pt)  osize(0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt) ocolor(white 			white white white white white white white white white )  clbreaks(0 1715 4038 6978 9703 13374 16587 21031 24555 35492 86616)     scalebar(units(10) scale(89.5)  label(Kilometers) xpos(100)) ///
		legend(size(9pt) pos(2)) point(data("Data/GPO.dta") xcoord(x) ycoord(y) size(medlarge) fcolor(gs0) ocolor(white) osize(1.5pt))
		graph export Analysis/roofrelative_Melbinnerfull.png, replace

		
		
		
		spmap roofrelative_outer using Data/poa_coord if Melbourne ==1 , id(id) fcolor(Greys2)   ///
		 clmethod(custom) ndfcolor(bluishgray) ndocolor(white) ndsize(0.001pt)  osize(0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt 0.001pt) ocolor(white 			white white white white white white white white white )  clbreaks(0 1715 4038 6978 9703 13374 16587 21031 24555 35492 86616)   scalebar(units(10) scale(89.5)  label(Kilometers) xpos(100) ypos(-90))  ///
		legend(off) point(data("Data/GPO.dta") xcoord(x) ycoord(y) fcolor(gs0) ocolor(white) osize(1.5pt))
		graph export Analysis/roofrelative_Melbouterfull.png, replace

		
